<?php
	
	function dbconnect() 
	{ 
		include('config.php'); 
		static $connect = null; 
		if ($connect === null) 
			{
				 $connect =  mysql_connect($host, $user, $passwd) or die(mysql_error());
				 mysql_query("SET character_set_results=utf8", $connect);
				 mysql_select_db($database); 
			} 
		return $connect; 
	} 
	
	function getbyid_hoadonnhap($id)
	{
		$result= mysql_query("SELECT * FROM Hoa_don_nhap WHERE ID=N'".$id."'",dbconnect());
		return mysql_fetch_array($result); 
	}
	function getbyid_ncc($id)
	{
		$result= mysql_query("SELECT * FROM Nha_cung_cap WHERE ID=N'".$id."'",dbconnect());
		return mysql_fetch_array($result); 
	}
	function getbyid_ctn($id)
	{
		$allnxb_req= mysql_query("SELECT * FROM Chi_tiet_nhap WHERE ID_Hoa_don_nhap=N'".$id."'",dbconnect());
		$result = array(); 
		while ($nxb = mysql_fetch_array($allnxb_req))
		 { 
			$result[] = $nxb; 
		 } 
		return $result;  
	}

	function getbyid_sach($id)
	{
		$result= mysql_query("SELECT * FROM Sach WHERE ID=N'".$id."'",dbconnect());
		return mysql_fetch_array($result); 
	}


	
?>